import mmap
import contextlib
import time

with open("node1.dat", "w") as fout:
    fout.write('\x00' * 1024)

i = 0

# node1
while True:
    with open("node1.dat", "r+") as fout:
        with contextlib.closing(mmap.mmap(fout.fileno(), 1024, access=mmap.ACCESS_WRITE)) as m_write:
            m_write.seek(0)
            i += 1
            s = "node1: How are you?" + str(i)
            s.rjust(1024, '\x00')
            m_write.write(s.encode())
            m_write.flush()
            time.sleep(1)
